package com.immunology.service;

import java.util.Map;

import com.immunology.dao.UserDao;
import com.immunology.database.transformers.UserTransformer;
import com.immunology.model.User;
import com.immunology.model.enums.Role;

public class CreateUserService {

	public User createUser(Map<String, String> parameters) {
		User user = new User();
		user.setFirstName(parameters.get("firstName"));
		user.setMiddleName(parameters.get("middleName"));
		user.setLastName(parameters.get("lastName"));
		user.setLogin(parameters.get("login"));
		user.setPassword(parameters.get("password"));
		user.setRole(Role.fromValue(parameters.get("role")));
		user.setPost(parameters.get("post"));
		UserDao userDao = new UserDao(new UserTransformer());
		userDao.insert(user);
		return user;
	}

}